cmake_minimum_required(VERSION 3.18.1)
set(ANDROID_PLATFORM android-31)
project("codec")
# 自动包含NDK系统头文件（推荐）
include_directories(${ANDROID_NDK}/sysroot/usr/include ${ANDROID_NDK}/sysroot/usr/include/android ${PROJECT_SOURCE_DIR})
# set(CLANG_TIDY_PATH "${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang-tidy")
# set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_PATH})
# set(CMAKE_CXX_CLANG_TIDY 
#     ${CLANG_TIDY_PATH}
#     -p=${CMAKE_BINARY_DIR}       # 指定 compile_commands.json 路径
# )
# set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# list(APPEND CMAKE_CXX_CLANG_TIDY
#     -checks=android-*,clang-analyzer-*,performance-*
# )
# 设置源文件目录
file(GLOB_RECURSE CODEC_SOURCES
    "jni/\*.cc"
    "src/\*.cc"
)

# 创建共享库
add_library(codec SHARED
    ${CODEC_SOURCES}
)
set(ARCH_LINK_FLAGS "-Wl,-z,max-page-size=16384")
#添加编译选项
target_link_options(codec PUBLIC ${ARCH_LINK_FLAGS})

# FFmpeg配置
include_directories(./third_party/ffmpeg/include)
set(LIB_DIR "./third_party/ffmpeg/lib")
file(GLOB_RECURSE ffmpeg "${LIB_DIR}/\*.so")

# 线程池配置
include_directories(./third_party/threadpool/include)
set(LIB_DIR "./third_party/threadpool/lib")
file(GLOB_RECURSE threadpool "${LIB_DIR}/\*.so")
find_library(AAUDIO_LIB aaudio)


target_link_libraries(codec android log nativehelper ${ffmpeg} ${threadpool} ${AAUDIO_LIB} EGL GLESv3)
